class CartesianProduct
  include Enumerable
  attr_accessor :res
  def initialize(a, b)
	@res = []
	a.each {|x| b.each {|y| @res.push([x, y])}}
	@res
  end
  def each
      for i in 0...@res.length
		yield @res[i]
      end
	#@res.each(|x| yield(x))
  end
  # your code here
end

c = CartesianProduct.new([:a,:b], [4,5])
c.each { |elt| puts elt.inspect }
# [:a, 4]
# [:a, 5]
# [:b, 4]
# [:b, 5]

c = CartesianProduct.new([:a,:b], [])
c.each { |elt| puts elt.inspect }
# (nothing printed since Cartesian product
# of anything with an empty collection is empty)


class SongList
  def [](key)
    if key.kind_of?(Integer)
      return @songs[key]
    else
      for i in 0...@songs.length
        return @songs[i] if key == @songs[i].name
      end
    end
    return nil
  end
end